function getAllCookie() {
  let cookie = document.cookie;

  let cookies = cookie.split(';');

  // console.log(cookies);
  let allCookie = {};
  for (let i = 0; i < cookies.length; i++) {
    allCookie[cookies[i].split("=")[0].trim()] = cookies[i].split("=")[1]  // "xx=xxx"
  }
  return allCookie
}

function getCookie(cname) {
  return getAllCookie()[cname] && cname + '=' + getAllCookie()[cname];
}

function setCookie(cname,value,exdays){
  let d = new Date();
  d.setTime(d.getTime()+(exdays*24*60*60*1000))
  let expirse = "expirse="+d.toUTCString();
  document.cookie = cname+'='+value+ '; '+expirse
}
